﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///CMSUser 的摘要说明
/// </summary>
public class CMSUser:Frame.BaseModel.FUser
{
	private  CMSUser()
	{
	}
    string[] Rights;
    public static bool Login(string UserName, string Pwd)
    {
        using (DAL.CMSDALDataContext dataContext = new DAL.CMSDALDataContext())
        {
            DAL.BI_User dUser =dataContext.BI_User
                .FirstOrDefault(o => o.UserCode == UserName && o.Pwd == Pwd);
            if (dUser == null)
            {
                return false;
            }
            else
            {
                Current = new CMSUser()
                {
                    ID = dUser.UserID,
                    IsAdmin=(dUser.IsAdmin==1),
                    m_isLogin =true,
                    Name = dUser.UserName,
                    Rights=dUser.Rights.Split('|')
                };
                return true;
            }
        }
    }

    public override bool CheckActionAllow(string ActionID)
    {
        if (!this.IsLogin)//当前是否登录用户
        {
            return false;
        }
        else
        {
            if (IsAdmin)//管理员账号，权限全开
            {
                return true;
            }
            else//其他人员的权限待补充
            {
                return Rights.Contains(ActionID);

            }
        }
    }
}